package com.google.cloud.testing.android.lib;

import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.view.View;

import org.hamcrest.Matcher;

import static org.hamcrest.Matchers.anything;

/**
 * {@link CloudUtils#takeScreenshot(String) Takes screenshot} and saves it as {@link #fileName}.
 */
class TakeScreenshotAction implements ViewAction {

    private final String fileName;

    TakeScreenshotAction(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public Matcher<View> getConstraints() {
        return anything();
    }

    @Override
    public String getDescription() {
        return "take screenshot";
    }

    @Override
    public void perform(UiController uiController, View view) {
        CloudUtils.takeScreenshotToFile(fileName);
    }
}
